import { fileURLToPath, URL } from 'node:url'
// import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
// import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// import VueDevTools from 'vite-plugin-vue-devtools'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
const baseURL = 'http://192.168.21.126:8080'
const baseURL2 = 'http://127.0.0.1:3000'


export default defineConfig({
  base:'login',
  plugins: [
    vue(),
    // VueDevTools(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    // createSvgIconsPlugin({
    //   // 图标文件夹为src/assets/icons
    //   iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
    //   // 指定symbolId格式
    //   symbolId: 'icon-[name]',
    // })

  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    proxy: {
      '/api': {
        target: baseURL, //目标url
        changeOrigin: true, //支持跨域
        rewrite: (path) => path.replace(/^\/api/, ""),
        //重写路径,替换/api
      }
    }
  }
})
